﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class DemoFollowerFactory : MonoBehaviour,IUIFollowerFactoryBase
{
    [SerializeField]
    private RectTransform hpImg;
    [SerializeField]
    private RectTransform nameDisplay;
    [SerializeField]
    private RectTransform tile;


    public List<FollowerElement> GenerateUIFollowerData()
    {
        var followerElements = new List<FollowerElement>();

        var hpElement = CreateFollowerElement(hpImg,Vector3.zero);
        var nameElement = CreateFollowerElement(nameDisplay,Vector3.up*30);
        var tileElement = CreateFollowerElement(tile,Vector3.up*40);

        followerElements.Add(hpElement);
        followerElements.Add(nameElement);
        followerElements.Add(tileElement);

        return followerElements;
    }

    private FollowerElement CreateFollowerElement(RectTransform element,Vector3 offset)
    {
        var copyed = Instantiate(element);
        copyed.gameObject.SetActive(true);

        copyed.SetParent(element.parent);
        var uiElement = new FollowerElement(copyed,offset);

        return uiElement;
    }
}
